# install pymilvus - `pip install pymilvus`
import asyncio

from agno.agent import Agent
from agno.knowledge.knowledge import Knowledge
from agno.vectordb.milvus import Milvus

# Initialize Milvus with local file
vector_db = Milvus(
    collection="recipes",
    uri="tmp/milvus.db",  # For local file-based storage
    # uri="http://localhost:19530"
)

# Create knowledge base
knowledge_base = Knowledge(
    vector_db=vector_db,
)

# Create agent with knowledge base
agent = Agent(knowledge=knowledge_base)

if __name__ == "__main__":
    # Load knowledge base asynchronously
    asyncio.run(knowledge_base.add_content_async(
            url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf"
        )
    )

    # Query the agent asynchronously
    asyncio.run(agent.aprint_response("如何制作Tom Kha Gai", markdown=True))